/*
 * standby.c
 *
 *  Created on: Nov 29, 2023
 *      Author: FFTAI
 */
#include  "standby.h"

 void standby( void )
 {

      GPIO_InitTypeDef GPIO_InitStructure = {0};

      EXTI_InitTypeDef EXTI_InitStructure = {0};

      NVIC_InitTypeDef NVIC_InitStructure = {0};

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|
      RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE|RCC_APB2Periph_AFIO, ENABLE);

       GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
       GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;

       GPIO_Init(GPIOA, &GPIO_InitStructure);
       GPIO_Init(GPIOB, &GPIO_InitStructure);
       GPIO_Init(GPIOC, &GPIO_InitStructure);
       GPIO_Init(GPIOD, &GPIO_InitStructure);
       GPIO_Init(GPIOE, &GPIO_InitStructure);


       GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource5);
       EXTI_InitStructure.EXTI_Line = EXTI_Line5;
       EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;
       EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
       EXTI_InitStructure.EXTI_LineCmd = ENABLE;
       EXTI_Init(&EXTI_InitStructure);


        NVIC_InitStructure.NVIC_IRQChannel =EXTI9_5_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        PWR_EnterSTANDBYMode();
 }
